var historyBoard = function() {
	var boardType1;
	var boardType2;
	var boardType3;
	var boardType4;
	return {
		/**
		 * 页面初始化方法
		 */
		init: function(param) {
			historyBoard._initPackCodeSelect(param);
			if(param != 'null'){
				$('#query_pack_code').html('<option value="'+param+'">'+param+'</option>').trigger("change");
			}
			historyBoard._initBoardType();
			historyBoard._initShortcutOfDate();
			historyBoard._bindBoardTypeChange();
			//$("#query_pack_code").val("QDLS201708170004");
			//$("#query_startTime").val("2017-09-21 00:42:07");
			//$("#query_endTime").val("2017-09-22 11:43:07");
			$("#btn_query").on('click',  function(e) {
				e.preventDefault();
				boardType1 = $("#board1").val();
				boardType2 = $("#board2").val();
				boardType3 = $("#board3").val();
				boardType4 = $("#board4").val();
				
				historyBoard._initBoard(boardType1,"history_board1");
				historyBoard._initBoard(boardType2,"history_board2");
				historyBoard._initBoard(boardType3,"history_board3");
				historyBoard._initBoard(boardType4,"history_board4");
			});
		},

		_initBoardType : function() {
			$("#board1").val("0");
			$("#board2").val("2");
			$("#board3").val("3");
			$("#board4").val("4");
		},

		_initShortcutOfDate : function() {
			/*$.ajax({
				"type": "post",
				"url": "main/realtimeBoard/getShortcutOfDate.mvc",
				"async": true,
				"dataType": "json",
				"success": function(res) {
					$("#query_startTime").val(res.yesterdayStart);
					$("#query_endTime").val(res.yesterdayEnd);
				}
			});*/

			$("#shortcut_time").on('change', function(e) {
				var _dateType = $("#shortcut_time").val();
				$.ajax({
					"type": "post",
					"url": "main/realtimeBoard/getShortcutOfDate.mvc",
					"async": true,
					"dataType": "json",
					"success": function(res) {
						if (_dateType == '0') {
							$("#query_startTime").val(res.yesterdayStart);
							$("#query_endTime").val(res.yesterdayEnd);
						} else if (_dateType == '1') {
							$("#query_startTime").val(res.beginDayOfLastWeek);
							$("#query_endTime").val(res.endDayOfLastWeek);
						} else if (_dateType == '2') {
							$("#query_startTime").val(res.beginDayOfLastMonth);
							$("#query_endTime").val(res.endDayOfLastMonth);
						} else if (_dateType == '3') {
							$("#query_startTime").val(res.beginOfLastQuarter);
							$("#query_endTime").val(res.endOfLastQuarter);
						} else if (_dateType == '4') {
							$("#query_startTime").val(res.beginOfLastYear);
							$("#query_endTime").val(res.endOfLastYear);
						}  else if (_dateType == '5') {
							$("#query_startTime").val('');
							$("#query_endTime").val('');
						}
					}
				});
			});
			
		},

		_initBoard : function(boardType,divId) {
			//echart需初始化
			//console.log("初始化看板:"+boardType+","+divId);
			switch (boardType) {
				case "0":
					historyBoard._initSocEcharts(divId);
					break;
				case "1":
					historyBoard._initTotalVolEcharts(divId);
					break;
				case "2":
					historyBoard._initCurrentEcharts(divId);
					break;
				case "3":
					historyBoard._initMaxTempEcharts(divId);
					break;
				case "4":
					historyBoard._initTempDataEcharts(divId);
					break;
				case "5":
					historyBoard._initVolDataEcharts(divId);
					break;
				case "6":
					historyBoard._initMonitoringPointTempEcharts(divId);
					break;
				case "7":
					historyBoard._initSingleVolEcharts(divId);
					break;
				case "8":
					historyBoard._initHistoryLocationMap(divId);
					break;
				default:
			}
		},

		_bindBoardTypeChange : function() {
			$("#board1").change(function(e) {
				var _boardType1 = $("#board1").val();
				historyBoard._initBoard(_boardType1,"history_board1");
			});
			$("#board2").change(function(e) {
				var _boardType2 = $("#board2").val();
				historyBoard._initBoard(_boardType2,"history_board2");
			});
			$("#board3").change(function(e) {
				var _boardType3 = $("#board3").val();
				historyBoard._initBoard(_boardType3,"history_board3");
			});
			$("#board4").change(function(e) {
				var _boardType4 = $("#board4").val();
				historyBoard._initBoard(_boardType4,"history_board4");
			});
		},


		_createBoardElement : function(divId) {
			var _prev = $("#"+divId).prev(".history-board");
			var _next = $("#"+divId).next(".history-board");
			var boardHtml = "<div class='history-board' id='"+divId+"' style='width:99%;min-height:400px;overflow: visible;height:auto !important;'></div>";
			$("#"+divId).remove();
			if(_prev.length>0){
				_prev.after(boardHtml);
			}else {
				_next.before(boardHtml);
			}
		},


		/**
		 * [_initPackCodeSelect 初始化电池下拉框]
		 * @return {[type]} [description]
		 */
		_initPackCodeSelect : function (pCode) {
			$("#query_pack_code").select2({
				language: "zh-CN",
				allowClear: true,
				width: "175px",
				placeholder: "请选择",
				ajax: {
					url: "monitor/historyQuery/getPackCodeOptions2.mvc",
					dataType: 'json',
					delay: 250,
					data: function (params) {
						params.offset = 10;
						params.page = params.page || 1;
						return {
							name: params.term,
							page: params.page,
							offset: params.offset
						};
					},
					cache: false,
					processResults: function (res, params) {
							var users = res.data;
							var options = [];
							for (var i = 0, len = users.length; i < len; i++) {
								var option = {
									"id": users[i]["serialNo"],
									"text": (users[i]["serialNo"])
								};
								options.push(option);
							}
							return {
								results: options,
								pagination: {
									more: (params.page * params.offset) < res.total
								}
							};
					},
					escapeMarkup: function (markup) {
						return markup;
					},
					minimumInputLength: 1
				}
			});
		},

		_initSocEcharts : function (divId) {
			$.ajax({
				"type": "post",
				"url": "monitor/historyQuery/getHistoryChartData.mvc",
				"async": true,
				"data": {
					'packCode': $("#query_pack_code").val(),
					'startTime': $("#query_startTime").val(),
					'endTime': $("#query_endTime").val(),
					'type': "0"
				},
				"dataType": "json",
				"beforeSend": function() {
					App.blockUI($("#"+divId));
				},
				"success": function(res) {
					var chart_datas = res;
					historyBoard._createBoardElement(divId);
					if(chart_datas && chart_datas.length >0){
						var gatherTimeData = new Array();
						var socData = new Array();
						for (var index = 0; index < chart_datas.length; index++) {
							gatherTimeData.push(chart_datas[index]['gatherTime']);
							socData.push(chart_datas[index] ['soc']);
						}
						var series = [{
							name: 'soc',
							type: 'line',
							data: socData,
							markPoint: {
								data: [{
									type: 'max',
									name: '最大值'
								}, {
									type: 'min',
									name: '最小值'
								}]
							}
						}];
						historyBoard._echartsConfig("SOC曲线图",['SOC'], gatherTimeData, '%', series, divId, 'SOC', "{b}<br/>{a} : {c}%");
					}else {
						rmsBox.notify('warning', {msg: '无SOC数据！',delay:3000});
					}
				},
				"error": function(msg) {
					console.log(msg);
					rmsBox.notify('error', {msg: '初始化图表信息失败！',delay:3000});
				},
				"complete": function() {
					App.unblockUI($("#"+divId));
				}
			});
		},

		_initTotalVolEcharts : function (divId) {
			$.ajax({
				"type": "post",
				"url": "monitor/historyQuery/getHistoryChartData.mvc",
				"async": true,
				"data": {
					'packCode': $("#query_pack_code").val(),
					'startTime': $("#query_startTime").val(),
					'endTime': $("#query_endTime").val(),
					'type': "1"
				},
				"dataType": "json",
				"beforeSend": function() {
					App.blockUI($("#"+divId));
				},
				"success": function(res) {
					var chart_datas = res;
					if(chart_datas && chart_datas.length >0){
						historyBoard._createBoardElement(divId);
						var gatherTimeData = new Array();
						var socData = new Array();
						var totalVolData = new Array();
						var totalElData = new Array();
						var maxTempData = new Array();
						var minTempData = new Array();
						var tempDiffData = new Array();
						var maxVolData = new Array();
						var minVolData = new Array();
						var volDiffData = new Array();
						for (var index = 0; index < chart_datas.length; index++) {
							gatherTimeData.push(chart_datas[index] ['gatherTime']);
							socData.push(chart_datas[index] ['soc']);
							totalVolData.push(chart_datas[index] ['totalVol']);
							totalElData.push(chart_datas[index] ['totalCurrent']);
							maxTempData.push(chart_datas[index] ['maxTemp']);
							minTempData.push(chart_datas[index] ['minTemp']);
							tempDiffData.push(chart_datas[index] ['tempDiff']);
							maxVolData.push(chart_datas[index] ['maxVol']);
							minVolData.push(chart_datas[index] ['minVol']);
							volDiffData.push(chart_datas[index] ['volDiff']);
						}
						var series = [{
							name: '总电压',
							type: 'line',
							data: totalVolData,
							markPoint: {
								data: [{
									type: 'max',
									name: '最大值'
								}, {
									type: 'min',
									name: '最小值'
								}]
							}
						}];
						historyBoard._echartsConfig("总电压曲线图",['总电压'], gatherTimeData, 'V', series, divId, '总电压(V)',"{b}<br/>{a} : {c}V");
					}else {
						rmsBox.notify('warning', {msg: '无总电压数据！',delay:3000});
					}
				},
				"error": function(msg) {
					console.log(msg);
					rmsBox.notify('error', {msg: '初始化图表信息失败！',delay:3000});
				},
				"complete": function() {
					App.unblockUI($("#"+divId));
				}
			});
		},

		_initCurrentEcharts : function (divId) {
			$.ajax({
				"type": "post",
				"url": "monitor/historyQuery/getHistoryChartData.mvc",
				"async": true,
				"data": {
					'packCode': $("#query_pack_code").val(),
					'startTime': $("#query_startTime").val(),
					'endTime': $("#query_endTime").val(),
					'type': "2"
				},
				"beforeSend": function() {
					App.blockUI($("#"+divId));
				},
				"dataType": "json",
				"success": function(res) {
					var chart_datas = res;
					if(chart_datas && chart_datas.length >0){
						historyBoard._createBoardElement(divId);
						var gatherTimeData = new Array();
						var totalElData = new Array();
						for (var index = 0; index < chart_datas.length; index++) {
							gatherTimeData.push(chart_datas[index] ['gatherTime']);
							totalElData.push(chart_datas[index] ['totalCurrent']);
						}
						var series = [{
							name: '总电流',
							type: 'line',
							data: totalElData,
							markPoint: {
								data: [{
									type: 'max',
									name: '最大值'
								}, {
									type: 'min',
									name: '最小值'
								}]
							}
						}];
						historyBoard._echartsConfig2("总电流曲线图",['总电流'], gatherTimeData, '', series, divId, '总电流(A)', "{b}<br/>{a} : {c}A");
					}else {
						rmsBox.notify('warning', {msg: '无总电流数据！',delay:3000});
					}
				},
				"error": function(msg) {
					console.log(msg);
					rmsBox.notify('error', {msg: '初始化图表信息失败！',delay:3000});
				},
				"complete": function() {
					App.unblockUI($("#"+divId));
				}
			});
		},

		_initMaxTempEcharts : function (divId) {
			$.ajax({
				"type": "post",
				"url": "monitor/historyQuery/getHistoryChartData.mvc",
				"async": true,
				"data": {
					'packCode': $("#query_pack_code").val(),
					'startTime': $("#query_startTime").val(),
					'endTime': $("#query_endTime").val(),
					'type': "3"
				},
				"dataType": "json",
				"beforeSend": function() {
					App.blockUI($("#"+divId));
				},
				"success": function(res) {
					var chart_datas = res;
					if(chart_datas && chart_datas.length >0){
						historyBoard._createBoardElement(divId);
						var gatherTimeData = new Array();
						var maxTempData = new Array();
						for (var index = 0; index < chart_datas.length; index++) {
							gatherTimeData.push(chart_datas[index] ['gatherTime']);
							maxTempData.push(chart_datas[index] ['maxTemp']);
						}
						var series = [{
							name: '监测点最高温度',
							type: 'line',
							data: maxTempData,
							markPoint: {
								data: [{
									type: 'max',
									name: '最大值'
								}, {
									type: 'min',
									name: '最小值'
								}]
							},
							itemStyle: {
								normal: {
									color: '#FB824E'
								}
							}
						}];
						historyBoard._echartsConfig("监测点最高温度曲线图",['监测点最高温度'], gatherTimeData, '℃', series, divId, '温度(℃)', "{b}<br/>{a} : {c}℃");
					}else {
						rmsBox.notify('warning', {msg: '无监测点最高温度数据！',delay:3000});
					}
				},
				"error": function(msg) {
					console.log(msg);
					rmsBox.notify('error', {msg: '初始化图表信息失败！',delay:3000});
				},
				"complete": function() {
					App.unblockUI($("#"+divId));
				}
			});
		},

		_initTempDataEcharts : function (divId) {
			$.ajax({
				"type": "post",
				"url": "monitor/historyQuery/getHistoryChartData.mvc",
				"async": true,
				"data": {
					'packCode': $("#query_pack_code").val(),
					'startTime': $("#query_startTime").val(),
					'endTime': $("#query_endTime").val(),
					'type': "4"
				},
				"beforeSend": function() {
					App.blockUI($("#"+divId));
				},
				"dataType": "json",
				"success": function(res) {
					var chart_datas = res;
					if(chart_datas && chart_datas.length >0){
						historyBoard._createBoardElement(divId);
						var gatherTimeData = new Array();
						var maxTempData = new Array();
						var minTempData = new Array();
						var tempDiffData = new Array();
						for (var index = 0; index < chart_datas.length; index++) {
							gatherTimeData.push(chart_datas[index] ['gatherTime']);
							maxTempData.push(chart_datas[index] ['maxTemp']);
							minTempData.push(chart_datas[index] ['minTemp']);
							tempDiffData.push(chart_datas[index] ['tempDiff']);
						}
						var series = [{
							name: '监测点最高温度',
							type: 'line',
							data: maxTempData,
							markPoint: {
								data: [{
									type: 'max',
									name: '最大值'
								}, {
									type: 'min',
									name: '最小值'
								}]
							}
						}, {
							name: '监测点最低温度',
							type: 'line',
							data: minTempData,
							markPoint: {
								data: [{
									type: 'max',
									name: '最大值'
								}, {
									type: 'min',
									name: '最小值'
								}]
							}
						}, {
							name: '温差',
							type: 'line',
							data: tempDiffData,
							yAxisIndex: 1,
							markPoint: {
								data: [{
									type: 'max',
									name: '最大值'
								}, {
									type: 'min',
									name: '最小值'
								}]
							}
						}];
						historyBoard._echartsConfig2Y("监测点温度极值与温差曲线图",['监测点最高温度', '监测点最低温度', '温差'], gatherTimeData, '℃', series, divId, '温度(℃)','温差(℃)', "{b}<br/>{a} : {c}℃");
					}else {
						rmsBox.notify('warning', {msg: '无监测点温度极值数据！',delay:3000});
					}
				},
				"error": function(msg) {
					console.log(msg);
					rmsBox.notify('error', {msg: '初始化图表信息失败！',delay:3000});
				},
				"complete": function() {
					App.unblockUI($("#"+divId));
				}
			});
		},

		_initVolDataEcharts : function (divId) {
			$.ajax({
				"type": "post",
				"url": "monitor/historyQuery/getHistoryChartData.mvc",
				"async": true,
				"data": {
					'packCode': $("#query_pack_code").val(),
					'startTime': $("#query_startTime").val(),
					'endTime': $("#query_endTime").val(),
					'type': "5"
				},
				"dataType": "json",
				"beforeSend": function() {
					App.blockUI($("#"+divId));
				},
				"success": function(res) {
					var chart_datas = res;
					if(chart_datas && chart_datas.length >0){
						historyBoard._createBoardElement(divId);
						var gatherTimeData = new Array();
						var maxVolData = new Array();
						var minVolData = new Array();
						var volDiffData = new Array();
						for (var index = 0; index < chart_datas.length; index++) {
							gatherTimeData.push(chart_datas[index] ['gatherTime']);
							maxVolData.push(chart_datas[index] ['maxVol']);
							minVolData.push(chart_datas[index] ['minVol']);
							volDiffData.push(chart_datas[index] ['volDiff']);
						}
						//单体电压与压差
						var series = [{
							name: '单体最高电压',
							type: 'line',
							data: maxVolData,
							markPoint: {
								data: [{
									type: 'max',
									name: '最大值'
								}, {
									type: 'min',
									name: '最小值'
								}]
							}
						}, {
							name: '单体最低电压',
							type: 'line',
							data: minVolData,
							markPoint: {
								data: [{
									type: 'max',
									name: '最大值'
								}, {
									type: 'min',
									name: '最小值'
								}]
							}
						}, {
							name: '压差',
							type: 'line',
							data: volDiffData,
							yAxisIndex: 1,
							markPoint: {
								data: [{
									type: 'max',
									name: '最大值'
								}, {
									type: 'min',
									name: '最小值'
								}]
							}
						}];
						historyBoard._echartsConfig2Y("单体电压极值与压差曲线图",['单体最高电压', '单体最低电压', '压差'], gatherTimeData, 'V', series, divId, '电压(V)', '压差(V)',"{b}<br/>{a} : {c}V");
					}else {
						rmsBox.notify('warning', {msg: '无单体电压极值数据！',delay:3000});
					}
				},
				"error": function(msg) {
					console.log(msg);
					rmsBox.notify('error', {msg: '初始化图表信息失败！',delay:3000});
				},
				"complete": function() {
					App.unblockUI($("#"+divId));
				}
			});
		},


		_initMonitoringPointTempEcharts : function (divId) {
			$.ajax({
				"type": "post",
				"url": "monitor/historyQuery/getHistoryChartData.mvc",
				"async": true,
				"data": {
					'packCode': $("#query_pack_code").val(),
					'startTime': $("#query_startTime").val(),
					'endTime': $("#query_endTime").val(),
					'type': "6"
				},
				"beforeSend": function() {
					App.blockUI($("#"+divId));
				},
				"dataType": "json",
				"success": function(res) {
					console.log(res);
					var chart_datas = res;
					if(chart_datas && chart_datas.length >0){
						historyBoard._createBoardElement(divId);
						var titleHtml = '<span class = "board-title"> 监测点温度值曲线</span>';
						$("#"+divId).append(titleHtml);
						$.each(chart_datas, function(i, item) {
							if(item.data.length>0) {
							//动态创建表格
								var chartHtml = "";
								chartHtml += '<li> <div class="echarts-title"> ';
								chartHtml += '<span class = "c-bold">第' + item.volGroupNo + '组</span>';
								chartHtml += '</div>';
								chartHtml += '<div id="'+divId+'_chart_' + i + '"class="echarts"></div>';
								$("#"+divId).append(chartHtml);
								var series = new Array();
								var legendData = new Array();
								$.each(item.data, function(k, single) {
									var s = {
										name: single.coreNo,
										type: 'line',
										data: single.yData,
										markPoint: {
											data: [{
												type: 'max',
												name: '最大值'
											}, {
												type: 'min',
												name: '最小值'
											}]
										}
									};
									series.push(s);
									legendData.push(single.coreNo);
								});

								historyBoard._echartsConfig2('',legendData, item.data[i].xData, "℃", series, divId+"_chart_" + i, "温度", "{b}<br/>{a} : {c}℃");
							}
						});
					}else {
						rmsBox.notify('warning', {msg: '无监测点温度数据！',delay:3000});
					}
				},
				"error": function(msg) {
					console.log(msg);
					rmsBox.notify('error', {msg: '初始化图表信息失败！',delay:3000});
				},
				"complete": function() {
					App.unblockUI($("#"+divId));
				}
			});
		},

		_initSingleVolEcharts : function (divId) {
			$.ajax({
				"type": "post",
				"url": "monitor/historyQuery/getHistoryChartData.mvc",
				"async": true,
				"data": {
					'packCode': $("#query_pack_code").val(),
					'startTime': $("#query_startTime").val(),
					'endTime': $("#query_endTime").val(),
					'type': "7"
				},
				"dataType": "json",
				"beforeSend": function() {
					App.blockUI($("#"+divId));
				},
				"success": function(res) {
					console.log(res);
					var chart_datas = res;
					if(chart_datas && chart_datas.length >0){
						historyBoard._createBoardElement(divId);
						var titleHtml = '<span class = "board-title"> 单体电压曲线</span>';
						$("#"+divId).append(titleHtml);
						$.each(chart_datas, function(i, item) {
							//动态创建表格
							if(item.data.length>0) {
								var chartHtml = "";
								chartHtml += '<li> <div class="echarts-title"> ';
								chartHtml += '<span class = "c-bold">第' + item.volGroupNo + '组</span>';
								chartHtml += '</div>';
								chartHtml += '<div id="'+divId+'_chart_' + i + '"class="echarts"></div>';
								$("#"+divId).append(chartHtml);
								var series = new Array();
								var legendData = new Array();
								$.each(item.data, function(k, single) {
									var s = {
										name: single.coreNo,
										type: 'line',
										data: single.yData,
										markPoint: {
											data: [{
												type: 'max',
												name: '最大值'
											}, {
												type: 'min',
												name: '最小值'
											}]
										}
									};
									series.push(s);
									legendData.push(single.coreNo);
								});
								historyBoard._echartsConfig2('',legendData, item.data[i].xData, "V", series, divId+"_chart_" + i, "电压", "{b}<br/>{a} : {c}V");
							}
						});
					}else {
						rmsBox.notify('warning', {msg: '无单体电压数据！',delay:3000});
					}
				},
				"error": function(msg) {
					console.log(msg);
					rmsBox.notify('error', {msg: '初始化图表信息失败！',delay:3000});
				},
				"complete": function() {
					App.unblockUI($("#"+divId));
				}
			});
		},

		_initHistoryLocationMap: function(divId) {
			//导出数据
			$("#"+divId).empty(); //清空地图内容
			var _titleHtml = '<span class = "board-title"> 历史轨迹</span>';
			$("#"+divId).append(_titleHtml);
			var _mapbox = "<div id='"+divId+"_map' style='width:100%;margin-top:20px;min-height:380px;overflow: hidden;height:auto !important;'></div>";
			$("#"+divId).append(_mapbox);
			var map = new BMap.Map(divId+"_map");
			map.centerAndZoom(new BMap.Point(116.417854, 39.921988), 5); //默认中心点
			map.enableScrollWheelZoom(true); //缩放
			//向地图中添加缩放控件  
			//向地图中添加缩略图控件  
			var _ctrlOve = new window.BMap.OverviewMapControl({
				anchor: BMAP_ANCHOR_BOTTOM_RIGHT,
				isOpen: 1
			});
			map.addControl(_ctrlOve);
			//向地图中添加比例尺控件  
			var _ctrlSca = new window.BMap.ScaleControl({
				anchor: BMAP_ANCHOR_BOTTOM_LEFT
			});
			map.addControl(_ctrlSca);
			var start_circle = new BMap.Symbol(BMap_Symbol_SHAPE_CIRCLE, {
				scale: 5.0,
				strokeWeight: 1.5,
				fillColor: 'blue',
				fillOpacity: 1.0
			});
			var circle = new BMap.Symbol(BMap_Symbol_SHAPE_CIRCLE, {
				scale: 5.0,
				strokeWeight: 1.5,
				fillColor: 'red',
				fillOpacity: 1.0
			});

			$.ajax({
				"type": "post",
				"url": "main/realtimeBoard/getHistoryLocationList.mvc",
				"dataType": "json",
				"async": true,
				"data": {
					'packCode': $("#query_pack_code").val(),
					'gatherTimeStart': $("#query_startTime").val(),
					'gatherTimeEnd': $("#query_endTime").val()

				},
				"beforeSend": function() {
					App.blockUI($("#"+divId));
				},
				"success": function(resp) {
					if (resp.aaData.length > 0) {
						//存在数据添加导出按钮
						var points = new Array();
						for (var i = 0; i < resp.aaData.length; i++) {
							points.push(new BMap.Point(parseFloat(resp.aaData[i].longitude), parseFloat(resp.aaData[i].latitude)));
							if (i == 0) {
								var marker = new BMap.Marker(new BMap.Point(parseFloat(resp.aaData[i].longitude), parseFloat(resp.aaData[i].latitude)), {
									icon: circle
								});
								map.addOverlay(marker);
							}
							if (i == (resp.aaData.length - 1)) {
								var marker = new BMap.Marker(new BMap.Point(parseFloat(resp.aaData[i].longitude), parseFloat(resp.aaData[i].latitude)), {
									icon: start_circle
								});
								map.addOverlay(marker);
							}
						}
						var polyline = new BMap.Polyline(
							points, {
								strokeColor: "green", //设置颜色   
								strokeWeight: 3, //宽度  
								strokeOpacity: 1
							}
						); //透明度  
						map.addOverlay(polyline);
						//缩放级别自适应
						var view = map.getViewport(eval(points));
						var mapZoom = view.zoom;
						var centerPoint = view.center;
						map.centerAndZoom(centerPoint, mapZoom);
					} else {
						//清空轨迹
						map.clearOverlays();
					}
				},
				"error": function(msg) {
					console.log(msg);
					rmsBox.notify('error', {msg: '初始化地图信息失败！',delay:3000});
				},
				"complete": function() {
					App.unblockUI($("#"+divId));
				}
			});
		},

		/**
		 * 配置echart 双Y轴
		 * @param title 图表标题
		 * @param legendData 系列
		 * @param dataX x轴数据
		 * @param unit y轴单位
		 * @param tooltipFormat tooltip格式化
		 * @param 系列数据
		 * @param chart_div_id 图表div_id
		 */
		_echartsConfig2Y: function(title, legendData, dataX, unit, series, chart_div_id, yaxisName, yaxisName2, tooltipFormat) {
			var option = {
				title: {
					text: title
				},
				tooltip: {
					trigger: 'axis',
					/*formatter: tooltipFormat*/
					formatter:function(params,ticket,callback) {
						var res= params[0].axisValue;
						 for (var i = 0, l = params.length; i < l; i++) {
                			res += '<br/>' + params[i].seriesName + ' : ' + params[i].value+unit;
            			}
            			//callback(ticket,res);
            			return res;
					}
				},
				legend: {
					data: legendData
				},
				toolbox: {
					show: true,
					feature: {
						dataZoom: {
							yAxisIndex: 'none'
						},
						restore: {},
						saveAsImage: {}
					}
				},
				/*dataZoom: {
					show: true,
					realtime: true,
					start: 0,
					end: 100
				},*/
				xAxis: {
					type: 'category',
					name: '时间',
					splitLine: {
						show: true
					},
					nameTextStyle: {
						color: '#89CBFD'
					},
					boundaryGap: true,
					data: dataX
				},
				yAxis: [{
					type: 'value',
					position: 'left',
					splitLine: {
						show: true
					},
					name: yaxisName,
					nameTextStyle: {
						color: '#89CBFD'
					},
					axisLabel: {
						formatter: '{value}' + unit
					},
					boundaryGap: [0.2, 0.2],
					min: 0
				}, {
					type: 'value',
					position: 'right',
					name: yaxisName2,
					nameTextStyle: {
						color: '#89CBFD'
					},
					axisLabel: {
						formatter: '{value}' + unit
					},
					boundaryGap: [0.2, 0.5],
					min: 0
				}],
				series: series
			};
			var myChart = echarts.init(document.getElementById(chart_div_id),'macarons');
			myChart.setOption(option);
		},



		_echartsConfig: function(title, legendData, dataX, unit, series, chart_div_id, yaxisName, tooltipFormat) {
			var option = {
				title: {
					text: title
				},
				tooltip: {
					trigger: 'axis',
					formatter:function(params,ticket,callback) {
						var res= params[0].axisValue;
						var l = params.length;

						if(l>9){
							for (var i = 0 ; i < (parseInt((l+1)/2)); i++) {
								if(2*i+1<l){
                					res += '<br/>' + params[2*i].seriesName + ' : ' + params[2*i].value+unit+'&nbsp;'+params[2*i+1].seriesName + ' : ' + params[2*i+1].value+unit;
								}else {
									res += '<br/>' + params[2*i].seriesName + ' : ' + params[2*i].value+unit;
								}
            				}
						}else {
							for (var i = 0; i < l; i++) {
                				res += '<br/>' + params[i].seriesName + ' : ' + params[i].value+unit;
            				}	
						}
						
            			//callback(ticket,res);
            			return res;
					}
				},
				legend: {
					data: legendData
				},
				toolbox: {
					show: true,
					feature: {
						dataZoom: {
							yAxisIndex: 'none'
						},
						restore: {},
						saveAsImage: {}

					}
				},
				xAxis: {
					type: 'category',
					name: '时间',
					splitLine: {
						show: true
					},
					nameTextStyle: {
						color: '#89CBFD'
					},
					boundaryGap: true,
					data: dataX
				},
				/*yAxis: {
					type: 'value',
					name: yaxisName,
					splitLine: {
						show: true
					},
					nameTextStyle: {
						color: '#89CBFD'
					},
					axisLabel: {
						formatter: '{value}' + unit
					},
					boundaryGap: [0.2, 0.5]
				},*/
				yAxis: [{
					type: 'value',
					scale: true,
					name: yaxisName,
					axisLabel: {
						formatter: '{value}' + unit
					},
					boundaryGap: [0.2, 0.2],
					min: 0
				}],
				series: series
			};
			var myChart = echarts.init(document.getElementById(chart_div_id),'macarons');
			myChart.setOption(option);
		},


		
		

		_echartsConfig2: function(title, legendData, dataX, unit, series, chart_div_id, yaxisName, tooltipFormat) {
			var option = {
				title: {
					text: title
				},
				tooltip: {
					trigger: 'axis',
					formatter:function(params,ticket,callback) {
						var res= params[0].axisValue;
						var l = params.length;

						if(l>9){
							for (var i = 0 ; i < (parseInt((l+1)/2)); i++) {
								if(2*i+1<l){
                					res += '<br/>' + params[2*i].seriesName + ' : ' + params[2*i].value+unit+'&nbsp;'+params[2*i+1].seriesName + ' : ' + params[2*i+1].value+unit;
								}else {
									res += '<br/>' + params[2*i].seriesName + ' : ' + params[2*i].value+unit;
								}
            				}
						}else {
							for (var i = 0; i < l; i++) {
                				res += '<br/>' + params[i].seriesName + ' : ' + params[i].value+unit;
            				}	
						}
						
            			//callback(ticket,res);
            			return res;
					}
				},
				legend: {
					data: legendData
				},
				toolbox: {
					show: true,
					feature: {
						dataZoom: {
							yAxisIndex: 'none'
						},
						restore: {},
						saveAsImage: {}

					}
				},
				xAxis: {
					type: 'category',
					name: '时间',
					splitLine: {
						show: true
					},
					nameTextStyle: {
						color: '#89CBFD'
					},
					boundaryGap: true,
					data: dataX
				},
				/*yAxis: {
					type: 'value',
					name: yaxisName,
					splitLine: {
						show: true
					},
					nameTextStyle: {
						color: '#89CBFD'
					},
					axisLabel: {
						formatter: '{value}' + unit
					},
					boundaryGap: [0.2, 0.5]
				},*/
				yAxis: [{
					type: 'value',
					scale: true,
					name: yaxisName,
					axisLabel: {
						formatter: '{value}' + unit
					},
					boundaryGap: [0.2, 0.2]
				}],
				series: series
			};
			var myChart = echarts.init(document.getElementById(chart_div_id),'macarons');
			myChart.setOption(option);
		},


	};

}();